package com.kyivmohyla.kma2.dao.mapper;

import com.kyivmohyla.kma2.model.Customer;
import org.springframework.jdbc.core.ResultSetExtractor;

import java.sql.ResultSet;
import java.sql.SQLException;


class CustomerResultSetExtractor implements ResultSetExtractor<Customer> {

    @Override
    public Customer extractData(ResultSet resultSet) throws SQLException {
        Customer customer = new Customer();
        try {
            customer.setCustomerId(resultSet.getInt("customer_id"));
            customer.setFirstName(resultSet.getString("first_name"));
            customer.setLastName(resultSet.getString("last_name"));
            customer.setAddress(resultSet.getString("address"));
            customer.setPhone(resultSet.getString("phone"));
            customer.setEmail(resultSet.getString("email"));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return customer;
    }

}